<?php 
/*
// "K2 Tools" Module by JoomlaWorks for Joomla! 1.5.x - Version 2.1
// Copyright (c) 2006 - 2009 JoomlaWorks Ltd. All rights reserved.
// Released under the GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
// More info at http://www.joomlaworks.gr and http://k2.joomlaworks.gr
// Designed and developed by the JoomlaWorks team
// *** Last update: September 9th, 2009 ***
*/

/*
// mod for K2 Extra fields Filter and Search module by Piotr Konieczny
// piotr@smartwebstudio.com
*/

// no direct access
defined('_JEXEC') or die('Restricted access');

require_once (dirname(__FILE__).DS.'helper.php');

// Params
$moduleclass_sfx = $params->get('moduleclass_sfx', '');
$advanced = $params->get('advanced', '0');
$field_type = $params->get('field_type', 'select');
$restrict_category = $params->get('restrict_category', '0');
$catid = $params->get('category', '0');
$all_langs = $params->get('all_langs', '0');
$field_id = $params->get('field_id', '1');
//search
$width = intval($params->get('width', 20));
$maxlength = $width > 20 ? $width : 20;
$text = $params->get('text', JText::_('search...'));
$button = $params->get('button', '');
$imagebutton = $params->get('imagebutton', '');
$button_text = $params->get('button_text', JText::_('Search'));
$button_pos = $params->get('button_pos', 'left');

JHTML::_('behavior.mootools'); //?
$document = &JFactory::getDocument();


// Output
$extra_fields_content = (
	modK2FilterHelper::extractExtraFields(
		modK2FilterHelper::pull($field_id,'')) 
);
$extra_fields_name = (
		modK2FilterHelper::pull($field_id,'name')
);

switch ($field_type) {

  case 'text':
	if ($imagebutton) {
		$img = modK2FilterHelper::getSearchImage($button_text);
	}
	require (JModuleHelper::getLayoutPath('mod_k2_filter', 'text'));
	break;
  
  case 'select':
	if ($imagebutton) {
		$img = modK2FilterHelper::getSearchImage($button_text);
	}
	require (JModuleHelper::getLayoutPath('mod_k2_filter', 'select'));
	break;

  case 'multi':
	if ($imagebutton) {
		$img = modK2FilterHelper::getSearchImage($button_text);
	}
	require (JModuleHelper::getLayoutPath('mod_k2_filter', 'multi'));
	break;

  case 'radio':
	if ($imagebutton) {
		$img = modK2FilterHelper::getSearchImage($button_text);
	}
	require (JModuleHelper::getLayoutPath('mod_k2_filter', 'radio'));
	break;

  default:
	echo '<p>Error: In this version of K2 Filter module type <cite>'.$field_type.'</cite> is not yet available</p>';
    break;
}

// Classes etc.